define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'dealer.shop/index',
        add_url: 'dealer.shop/add',
        edit_url: 'dealer.shop/edit',
        delete_url: 'dealer.shop/delete',
        export_url: 'dealer.shop/export',
        modify_url: 'dealer.shop/modify',
    };

    return {
        index: function () {
            ea.table.render({
                init: init,
                toolbar:[],
                defaultToolbar:['filter'],
                cols: [[
                    {field: 'identity_salesman', title: '业务员' ,search:'false'},
                    {field: 'shop_name', title: '店铺名称'},
                    {field: 'name', title: '姓名'},
                    {field: 'phone', title: '联系方式'},
                    {field: 'store_images', title: '门店图片', templet: ea.table.lazyimg ,search:'false'},
                    {field: 'business_license_images', title: '营业执照', templet: ea.table.lazyimg ,search:'false'},
                    {field: 'identity_card_just_images', title: '身份证头像面', templet: ea.table.lazyimg ,search:'false'},
                    {field: 'identity_card_back_images', title: '身份证国徽面', templet: ea.table.lazyimg ,search:'false'},
                    // {field: 'status', title: '状态', templet: ea.table.switch,search:'false'},
                    {field: 'indent_goods_num', title: '订购数量', Width: 40 ,search:'false'
                        ,templet: function(d){
                            if (d.indent_goods_num == null) {
                                return'0';
                            } else {
                                return d.indent_goods_num;
                            }
                        }},
                    {field: 'display_status', title: '售卖状态', search:'false'
                    ,templet: function(d){
                        if (d.display_status == 0) {
                            return '已限制';
                        } else if (d.display_status == 1) {
                            return '正常';
                        } else{
                            return '-';
                        }
                    }},
                    {field: 'examine_status', title: '审核状态' ,selectList: {"0":"待审核","1":"通过","2":"驳回"},},
                    // {field: 'goods_id', title: '代理商品'},
                    {field: 'qrcode_image', title: '二维码', templet: ea.table.lazyimg ,search:'false'},
                    // {field: 'shop_remind', title: '店铺提点',search:'false'
                    // ,templet: function(d){
                    //     return d.shop_remind+'%';
                    // }},
                    {field: 'count_order', title: '订单数', Width: 40,search:'false'},
                    {field: 'count_goods_num', title: '销售数量', Width: 40,search:'false'
                    ,templet: function(d){
                        if (d.count_goods_num == null) {
                            return'0';
                        } else {
                            return d.count_goods_num;
                        }
                    }},
                    {field: 'count_order_price', title: '销售额', Width: 40 ,search:'false'
                    ,templet: function(d){
                        if (d.count_order_price == null) {
                            return'￥0.00';
                        } else {
                            return '￥'+d.count_order_price;
                        }
                    }},
                    {field: 'shop_address',title: '店铺地址',search:'false' ,templet: function(d){
                        return d.province+''+d.city+''+d.area+''+d.shop_address;
                    }},
                    {field: 'create_time', minWidth: 100, title: '创建时间', search: 'range'},
                    {width: 100, title: '操作', templet: ea.table.tool
                        ,operat:['edit']
                    },

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
});